//
//  Router.swift
//  应用路由管理
//
//  Created by chen on 2025/5/2.
//

import Foundation

class Router: ObservableObject {
    
    static let shared = Router()
    
    private init() {}
    
    @Published var path: [AppRoute] = []
    
    func to(_ route: AppRoute) {
        if path.last != route {
            path.append(route)
        }
    }
    
    func toRoot() {
        path.removeAll()
    }
    
    func back() {
        if !path.isEmpty {
            path.removeLast()
        }
    }
    
}
